/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import control.AnsatHandler;
import control.GuiHandler;
import java.awt.Color;
import java.awt.Component;

/**
 *
 * @author Morten J, Morten B & Jonas
 */
public class GUI extends javax.swing.JFrame {

    private BrugerLogin brugerlogin;
    private Lager lager;
    private Kasse kasse;
    private Statistik statistik;
    private static GuiHandler guiHandler;

    /**
     * Creates new form GUI
     */
    public GUI() {
        brugerlogin = new BrugerLogin();
        lager = new Lager();
        kasse = new Kasse();
        statistik = new Statistik();
        initComponents();
        this.getContentPane().setBackground(new Color(186, 153, 108));
        setResizable(false);
        jContent.add(brugerlogin);
        jContent.add(lager);
        jContent.add(kasse);
        jContent.add(statistik);
        brugerlogin.setSize(jContent.getWidth(), jContent.getHeight());
        lager.setSize(jContent.getWidth(), jContent.getHeight());
        kasse.setSize(jContent.getWidth(), jContent.getHeight());
        statistik.setSize(jContent.getWidth(), jContent.getHeight());
        setNavVisible(false);
        guiHandler = new GuiHandler(this, brugerlogin, lager, kasse, statistik);

    }

    public static GuiHandler getGuiHandler() {
        return guiHandler;
    }

    public void toogleLogOut(boolean state) {
        jBtnLogout.setEnabled(state);
    }

    public void setNavVisible(boolean e) {
        if (e) {
            jNavigation.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(250, 250, 250)), "Navigation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 10), new java.awt.Color(240, 240, 240)));
        } else {
            jNavigation.setBorder(null);
        }
        for (Component c : jNavigation.getComponents()) {
            c.setVisible(e);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jNavigation = new javax.swing.JPanel();
        jBtnLogout = new javax.swing.JButton();
        jBtnKasse = new javax.swing.JButton();
        jBtnLager = new javax.swing.JButton();
        jBtnStatistik = new javax.swing.JButton();
        jLabWelcome = new javax.swing.JLabel();
        jLabLoginName = new javax.swing.JLabel();
        jPanBanner = new javax.swing.JPanel();
        jBannerLogo = new javax.swing.JLabel();
        jContent = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Museum Sydøstdanmark");

        jNavigation.setBackground(java.awt.Color.darkGray);
        jNavigation.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(250, 250, 250)), "Navigation", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 10), new java.awt.Color(240, 240, 240))); // NOI18N
        jNavigation.setToolTipText("");

        jBtnLogout.setBackground(java.awt.Color.darkGray);
        jBtnLogout.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jBtnLogout.setForeground(new java.awt.Color(250, 250, 250));
        jBtnLogout.setText("Log ud");
        jBtnLogout.setBorder(null);
        jBtnLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnLogoutActionPerformed(evt);
            }
        });

        jBtnKasse.setBackground(new java.awt.Color(218, 191, 137));
        jBtnKasse.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jBtnKasse.setForeground(new java.awt.Color(25, 25, 25));
        jBtnKasse.setText("Kasse");
        jBtnKasse.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jBtnKasse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnKasseActionPerformed(evt);
            }
        });

        jBtnLager.setBackground(new java.awt.Color(218, 191, 137));
        jBtnLager.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jBtnLager.setForeground(new java.awt.Color(25, 25, 25));
        jBtnLager.setText("Vareliste");
        jBtnLager.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jBtnLager.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnLagerActionPerformed(evt);
            }
        });

        jBtnStatistik.setBackground(new java.awt.Color(218, 191, 137));
        jBtnStatistik.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jBtnStatistik.setForeground(new java.awt.Color(25, 25, 25));
        jBtnStatistik.setText("Statistik");
        jBtnStatistik.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jBtnStatistik.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnStatistikActionPerformed(evt);
            }
        });

        jLabWelcome.setFont(new java.awt.Font("Verdana", 0, 11)); // NOI18N
        jLabWelcome.setForeground(new java.awt.Color(250, 250, 250));
        jLabWelcome.setText("Velkommen");

        jLabLoginName.setFont(new java.awt.Font("Verdana", 1, 11)); // NOI18N
        jLabLoginName.setForeground(new java.awt.Color(250, 250, 250));

        javax.swing.GroupLayout jNavigationLayout = new javax.swing.GroupLayout(jNavigation);
        jNavigation.setLayout(jNavigationLayout);
        jNavigationLayout.setHorizontalGroup(
            jNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jNavigationLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBtnKasse)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBtnLager)
                .addGap(30, 30, 30)
                .addComponent(jBtnStatistik)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabWelcome, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabLoginName, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBtnLogout)
                .addContainerGap())
        );
        jNavigationLayout.setVerticalGroup(
            jNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jNavigationLayout.createSequentialGroup()
                .addGroup(jNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabLoginName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jNavigationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jBtnKasse)
                        .addComponent(jBtnLager)
                        .addComponent(jBtnLogout, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabWelcome)
                        .addComponent(jBtnStatistik)))
                .addGap(2, 2, 2))
        );

        jPanBanner.setBackground(java.awt.Color.darkGray);

        jBannerLogo.setBackground(java.awt.Color.darkGray);
        jBannerLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jBannerLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/museumsyd.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanBannerLayout = new javax.swing.GroupLayout(jPanBanner);
        jPanBanner.setLayout(jPanBannerLayout);
        jPanBannerLayout.setHorizontalGroup(
            jPanBannerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jBannerLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanBannerLayout.setVerticalGroup(
            jPanBannerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanBannerLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jBannerLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 89, Short.MAX_VALUE))
        );

        jContent.setBackground(new java.awt.Color(186, 153, 108));

        javax.swing.GroupLayout jContentLayout = new javax.swing.GroupLayout(jContent);
        jContent.setLayout(jContentLayout);
        jContentLayout.setHorizontalGroup(
            jContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jContentLayout.setVerticalGroup(
            jContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jNavigation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jContent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jPanBanner, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanBanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jNavigation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(jContent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtnKasseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnKasseActionPerformed
        guiHandler.showKasse();
    }//GEN-LAST:event_jBtnKasseActionPerformed

    private void jBtnLagerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnLagerActionPerformed
        guiHandler.showLager();
    }//GEN-LAST:event_jBtnLagerActionPerformed

    private void jBtnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnLogoutActionPerformed
        guiHandler.showBrugerlogin();
        setNavVisible(false);
    }//GEN-LAST:event_jBtnLogoutActionPerformed

    private void jBtnStatistikActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnStatistikActionPerformed
        guiHandler.showStatistik();
    }//GEN-LAST:event_jBtnStatistikActionPerformed

    public void setAnsatNavn() {
        jLabLoginName.setText(AnsatHandler.getAktuelAnsat().getfNavn() + " " + AnsatHandler.getAktuelAnsat().geteNavn());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
        } catch (InstantiationException ex) {
        } catch (IllegalAccessException ex) {
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jBannerLogo;
    private javax.swing.JButton jBtnKasse;
    private javax.swing.JButton jBtnLager;
    private javax.swing.JButton jBtnLogout;
    private javax.swing.JButton jBtnStatistik;
    private javax.swing.JPanel jContent;
    private javax.swing.JLabel jLabLoginName;
    private javax.swing.JLabel jLabWelcome;
    private javax.swing.JPanel jNavigation;
    private javax.swing.JPanel jPanBanner;
    // End of variables declaration//GEN-END:variables
}
